<template>
	<view class="ReleaseEvaluation">
		<view class="navHead" :style="{'padding-top':statusH+'px'}">
			<view class="navHeadCon">
				<image src="../../static/index/back.png" class="back" @click="back"></image>
				<view class="navTit">测评列表</view>
				<view class="allChoice" @click="toExport">
					<image src="../../static/mine/export.png"></image>
					<view>导出</view>
				</view>
			</view>
		</view>
		<view class="emptyBox" :style="{'padding-top':statusH+'px'}"></view>
		<view class="ReleaseEvaluationBox">
			<view class="contentList">
				<view class="contentItem" :class="{contentItem_OP:item.endFlag}" v-for="(item,index) in conList" :data-id="item.id" @click="toEdit">
					<view class="contentItem_top">
						<view class="contentImage">
							<image :src="getImgUrl(item.ShopEvaluationExampleImage[0].image_url)" mode="" v-if="item.ShopEvaluationExampleImage.length>0"></image>
						</view>
						<view class="content_R">
							<view class="contentNameBox">
								<view class="contentItemName">{{item.title}}</view>
								<view class="Royalties" v-if="!item.endFlag">稿费￥{{item.talent_money}}</view>
								<view class="Royalties RoyaltiesColor" v-else>已结束</view>
							</view>
							<view class="addressBox">
								<view class="fieldBox">
									<view class="fieldtitle">领域</view>
									<view class="fieldtext">{{item.shopObj.Shop.industry.name}}</view>
								</view>
								<view class="addressNum">{{item.shopObj.distance}}km</view>
							</view>
							<view class="fansBox">
								<view class="fansIcon" v-if="item.platform==1">
									<image src="/static/index/fans.png" mode=""></image>
								</view>
								<view class="fansIcon" v-if="item.platform==2" style="background: #F40A0B;">
									<image src="../../static/mine/xiaohongshu_white.png" mode="widthFix" style="width: 36upx;"></image>
								</view>
								<view class="fansIcon" v-if="item.platform==3" style="background: #FFD974;">
									<image src="../../static/mine/weibo_white.png" mode="widthFix" style="width: 20upx;"></image>
								</view>
								<view class="fansIcon" v-if="item.platform==4" style="background: #F36326;">
									<image src="../../static/mine/dazong_white.png" mode="heightFix" style="height: 24upx;"></image>
								</view>
								
								<view class="fanstext"><text>粉丝数{{item.fans_num}}以上</text><text v-if="item.platform==4">;等级{{item.public_grade}}以上</text></view>
							</view>
							<view class="recommendBox">
								<view class="recommendtitle">内容</view>
								<view class="recommendtext">{{item.content}}</view>
							</view>
							
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				page:1,
				conList:[],
				moreFlag:false,
				statusH:""
			}
		},
		onReachBottom() {
			if(!this.moreFlag){
				return false;
			}
			this.moreFlag = false;
			this.page = this.page + 1;
			this.getList();
		},
		onLoad() {
      // #ifdef APP-PLUS
      var args = plus.runtime.arguments;
      if(args){
        app.$vm.setShareDetail(args);
      }
      // #endif
			uni.getSystemInfo({
				success:res=>{
					this.statusH = res.statusBarHeight;
				}
			})
			if(app.$vm.globalData.latitude){
				this.getList();
			}else{
				Promise.all([app.$vm.indexInitFun()]).then(res=>{
					this.getList();
				})
			}
		},
		methods: {
			toEdit(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				uni.navigateTo({
					url:"/pages/pagefour/pages/releaseEva/releaseEva?id="+id
				})
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			toExport(){
				uni.navigateTo({
					url:"/pages/pagetwo/pages/exportGroup/exportGroup?type=cp"
				})
			},
			getImgUrl(url){
				if(url&&(url.indexOf("http://")!=-1||url.indexOf("https://")!=-1)){
					return url;
				}else{
					return app.$vm.globalData.imgBaseUrl + url;
				}
			},
			getList(){
				let obj = {};
				obj.user_id = uni.getStorageSync("userId");
				obj.end_time = 1;
				let newObj = {};
				newObj.page = this.page;
				newObj.data = obj;
				this.$u.api.shopEvaluationList(newObj).then(res=>{
					console.log(res)
					if(this.page==1){
						this.conList = res.data.list.data.map(cur=>{
							if(cur.end_time<Math.floor(new Date().getTime()/1000)){
								cur.endFlag = true;
							}else{
								cur.endFlag = false;
							}
							cur.ShopEvaluationRelation = cur.ShopEvaluationRelation.map(pcur=>{
								let dis = app.$vm.getDistance(Number(pcur.Shop.dimension),Number(pcur.Shop.longitude));
								pcur.distance = dis;
								return pcur;
							})
							return cur;
						});
					}else{
						this.conList = this.conList.concat(res.data.list.data.map(cur=>{
							if(cur.end_time<Math.floor(new Date().getTime()/1000)){
								cur.endFlag = true;
							}else{
								cur.endFlag = false;
							}
							cur.ShopEvaluationRelation = cur.ShopEvaluationRelation.map(pcur=>{
								let dis = app.$vm.getDistance(Number(pcur.Shop.dimension),Number(pcur.Shop.longitude));
								pcur.distance = dis;
								return pcur;
							})
							return cur;
						}));
					}
					this.conList = this.conList.map(cur=>{
						let obj = {};
						for(let i=0;i<cur.ShopEvaluationRelation.length;i++){
							if(i==0){
								obj = cur.ShopEvaluationRelation[i];
							}else{
								if(cur.ShopEvaluationRelation[i].distance<obj.distance){
									obj = cur.ShopEvaluationRelation[i];
								}
							}
						}
						cur.shopObj = obj;
						return cur;
					})
					if(this.page<res.data.list.last_page){
						this.moreFlag = true;
					}else{
						this.moreFlag = false;
					}
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.emptyBox{
		width: 100%;
		height: 88upx;
		box-sizing: content-box;
	}
	.navHead{
		position: fixed;
		width: 100%;
		left: 0;
		top: 0;
		background: white;
		z-index: 999;
	}
	.navHeadCon{
		width: 100%;
		height: 88upx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
	}
	.back{
		width: 48upx;
		height: 48upx;
		position: absolute;
		left: 24upx;
		top: 50%;
		transform: translateY(-50%);
	}
	.navTit{
		font-size: 28upx;
		color: #333333;
		line-height: 88upx;
		text-align: center;
	}
	.allChoice{
		position: absolute;
		right: 32upx;
		height: 88upx;
		top: 0;
		display: flex;
		align-items: center;
	}
	.allChoice>view{
		font-size: 28upx;
		line-height: 88upx;
		color: #333333;
	}
	.allChoice>image{
		width: 28upx;
		height: 28upx;
		margin-right: 6upx;
	}
	
	
	
.ReleaseEvaluation{
	background-color: #F3F3F3;
	height: 100vh;
	overflow: auto;
	.ReleaseEvaluationBox{
		padding: 16upx 24upx;
		.contentList{
			// margin-top: 24upx;
			.contentItem{
				width: 702upx;
				background: #FFFFFF;
				opacity: 1;
				border-radius: 20upx;
				margin-bottom: 16upx;
				.contentItem_top{
					display: flex;
					padding: 32upx 0 24upx 24upx;
					.contentImage{
						width: 144upx;
						height: 144upx;
						border-radius: 8upx;
						margin-right: 16upx;
						image{
							width: 100%;
							height: 100%;
						}
					}
					.content_R{
						width: calc(100% - 160upx);
						.contentNameBox{
							display: flex;
							align-items: center;
							justify-content: space-between;
							.contentItemName{
								font-size: 24upx;
								color: #333333;
							}
							.Royalties{
								// width: 92upx;
								// height: 32upx;
								background: linear-gradient(206deg, #FAD96C 0%, #FFAC3F 100%);
								opacity: 1;
								border-radius: 20upx 0 0 20upx;
								font-size: 16upx;
								color: #fff;
								text-align: center;
								padding: 8upx;
							}
							.RoyaltiesColor{
								width: 92upx;
								background: linear-gradient(206deg, #C0C0C0 0%, #D3D3D3 100%);
								opacity: 1;
								border-radius: 20upx 0 0 20upx;
								font-size: 16upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #FFFFFF;
							}
						}
						.addressBox{
							display: flex;
							align-items: center;
							justify-content: space-between;
							margin-top: 8upx;
							padding-right: 24upx;
							.address{
								font-size: 16upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #999999;
							}
							.addressNum{
								font-size: 16upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #999999;
							}
						}
						.fansBox{
							display: flex;
							align-items: center;
							margin-top: 8upx;
							.fansIcon{
								display: flex;
								justify-content: center;
								align-items: center;
								width: 48upx;
								height: 24upx;
								background: #260A20;
								opacity: 1;
								border-radius: 4upx;
								image{
									width: 24upx;
									height: 24upx;
								}
							}
							.fanstext{
								width: calc(100% - 48upx);
								font-size: 20upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #333333;
								margin-left: 8upx;
								overflow: hidden;
								text-overflow: ellipsis;
								white-space: nowrap;
							}
						}
						.recommendBox{
							display: flex;
							align-items: center;
							margin-top: 8upx;
							.recommendtitle{
								width: 48upx;
								height: 24upx;
								background: #FFAC3F;
								opacity: 1;
								border-radius: 4upx;
								font-size: 16upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								text-align: center;
								line-height: 24upx;
								color: #FFFFFF;
								// padding: 4upx;
								// box-sizing: border-box;
								margin-right: 8upx;
							}
							.recommendtext{
								width: calc(100% - 48upx);
								font-size: 20upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #333333;
								overflow: hidden;
								text-overflow: ellipsis;
								white-space: nowrap;
							}
						}
						.fieldBox{
							display: flex;
							align-items: center;
							// margin-top: 18upx;
							.fieldtitle{
								width: 48upx;
								height: 24upx;
								background: #FF5555;
								opacity: 1;
								border-radius: 4upx;
								font-size: 16upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								line-height: 24upx;
								text-align: center;
								color: #FFFFFF;
								// padding: 4upx;
							}
							.fieldtext{
								// width: calc(100% - 48upx);
								font-size: 20upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #333333;
								margin-left: 8upx;
								overflow: hidden;
								white-space: nowrap;
								text-overflow: ellipsis;
							}
						}
					}
				}
			}
			.contentItem_OP{
				opacity: 0.5;
			}
		}
	}
}
</style>
